package org.FaPe3D.engine.materials
{
	import org.FaPe3D.utils.RegisterProperties;
	import org.papervision3d.materials.ColorMaterial;

	public class FPColorMaterial extends ColorMaterial
	{
		private var _color:Number;
		private var _alpha:Number;
		private var _object:Object;
		
		public function FPColorMaterial(obj:Object = null,color:Number=0xFF00FF, alpha:Number=1, interactive:Boolean=false)
		{
			_object = obj;
			_color = color;
			_alpha = alpha;
			super(color, alpha, interactive);
		}
		
		private function _material():ColorMaterial
		{
			var mat:ColorMaterial = new ColorMaterial(_color,_alpha,this.interactive);
			RegisterProperties.register(mat,_object);
			return mat
		}
		
		public function get color():Number
		{
			return _color;
		}
		
		public function set color(colorize:Number)
		{
			_color = colorize;
			this.copy(_material());
		}
		
		public function get alpha():Number
		{
			return _alpha;
		}
		
		public function set alpha(transparency:Number)
		{
			_alpha = transparency;
			this.copy(_material());
		}
		
		public override function toString(): String
		{
			return 'FPColorMaterial - color:' + this.fillColor + ' alpha:' + this.fillAlpha;
		}
		
	
	}
}